#include "SubSessionMgr.h"
#include "SubsessionEventHandler.h"
#include "ProxyMgr.h"
#include "Proxy.h"

void CSubSessionMgr::on_accept( utility::network::session * pSession)
{
    if (CProxy * pProxy = CProxyMgr::Instance()->Find(pSession->get_local_ip(), pSession->get_local_port()))
    {
        CSubsessionEventHandler * pHandler = m_EventHandlers.construct(pSession);
        pSession->set_event_handler(pHandler);
        pProxy->SetSvrEventHandler(pHandler);
    }
    else
        pSession->disconnect();
}

void CSubSessionMgr::RecycleEventHandler( CSubsessionEventHandler * pHandler)
{
    m_EventHandlers.destroy(pHandler);
}
